From 04866d25fd0bba98d1d203b9065e2f54856c7eaa Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Sat, 10 Mar 2007 16:22:52 +0000 Subject: [PATCH] xen: Fix VCPUOP_set_periodic_timer return value. Clean up vcpu_op() code, and fix a couple of comments. Signed-off-by: Keir Fraser --- xen/common/domain.c | 20 ++++++++------------ xen/common/schedule.c | 4 ++-- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 00ca0d7aa6..7b4660fc91 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -546,16 +546,12 @@ long do_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg) { case VCPUOP_initialise: if ( (ctxt = xmalloc(struct vcpu_guest_context)) == NULL ) - { - rc = -ENOMEM; - break; - } + return -ENOMEM; if ( copy_from_guest(ctxt, arg, 1) ) { xfree(ctxt); - rc = -EFAULT; - break; + return -EFAULT; } LOCK_BIGLOCK(d); @@ -569,9 +565,11 @@ long do_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg) case VCPUOP_up: if ( !test_bit(_VCPUF_initialised, &v->vcpu_flags) ) - rc = -EINVAL; - else if ( test_and_clear_bit(_VCPUF_down, &v->vcpu_flags) ) + return -EINVAL; + + if ( test_and_clear_bit(_VCPUF_down, &v->vcpu_flags) ) vcpu_wake(v); + break; case VCPUOP_down: @@ -596,13 +594,11 @@ long do_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg) { struct vcpu_set_periodic_timer set; - rc = -EFAULT; if ( copy_from_guest(&set, arg, 1) ) - break; + return -EFAULT; - rc = -EINVAL; if ( set.period_ns < MILLISECS(1) ) - break; + return -EINVAL; v->periodic_period = set.period_ns; vcpu_force_reschedule(v); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 447cc2744e..f78319e381 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -110,7 +110,7 @@ int sched_init_vcpu(struct vcpu *v, unsigned int processor) else cpus_setall(v->cpu_affinity); - /* Initialise the per-domain timers. */ + /* Initialise the per-vcpu timers. */ init_timer(&v->periodic_timer, vcpu_periodic_timer_fn, v, v->processor); init_timer(&v->singleshot_timer, vcpu_singleshot_timer_fn, @@ -471,7 +471,7 @@ ret_t do_sched_op(int cmd, XEN_GUEST_HANDLE(void) arg) #ifndef COMPAT -/* Per-domain one-shot-timer hypercall. */ +/* Per-vcpu oneshot-timer hypercall. */ long do_set_timer_op(s_time_t timeout) { struct vcpu *v = current; -- 2.30.2